<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
			$(function(){
				$("#btnSearch").button({
		            icons: {
		                primary: "ui-icon-search"
		            }
		        }).click(function(){
					if(validateEmpty()){
						$("#searchForm").submit();
					} else {
						return false;
					}
				});
				$("#btnEdit").button({
		            icons: {
		                primary: "ui-icon-disk"
		            }
		        }).click(function(){
					$("#job").val("update");
		        	$("#searchForm").submit();
				});
		        thaiDatepicker("transactionTimestamp","#","1");
		        thaiDatepicker("expenseDate","#","1");
			});
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC60502')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60502"/>
		<input type="hidden" name="job" id="job" value="search"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC60502}</b></th>
			</tr>
			<tr>
				<td class="bold" width="20%">จังหวัด : </td>
				<td>
					<select name="provinceId" id="provinceId">
						<option value="">----- เลือก -----</option>
							<c:forEach var="data" items="${listProvince}">
							<c:if test="${data.PROVINCE_ID == provinceId}" var="provinceSeleted"/>
							<option value="${data.PROVINCE_ID}" ${provinceSeleted?'selected':''}>${data.PROVINCE_NAME}</option>
						</c:forEach>
					</select>
				</td>
			</tr>
			<tr>
				<td class="bold">วันที่ทำรายการ : </td>
				<td>
					<input type="text" name="transactionTimestamp" id="transactionTimestamp" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${transactionTimestamp}"/>
					<span id="#transactionTimestamp" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td class="bold">วันที่สั่งจ่าย : </td>
				<td>
					<input type="text" name="expenseDate" id="expenseDate" size="12" maxlength="10" onkeypress="return numberAndSlash(event);" onblur="dateFormat(this);" value="${expenseDate}"/>
					<!-- <span id="#expenseDate" class="red">*</span> -->
				</td>
			</tr>
			<tr>
				<td class="bold">สถานะ : </td>
				<td>
					<input type="radio" name="status" id="succeed" value="succeed" ${status=='succeed'?'checked':''}/> ทำรายการแล้ว <!-- Reson code not null -->
					<input type="radio" name="status" id="fail" value="fail" ${status=='fail'?'checked':''}/> ยังไม่ทำรายการ<!-- Reson code null -->
				</td>
			</tr>
			<tr>
				<td align="center" colspan="2">
					<button type="button" name="btnSearch" id="btnSearch" class="acc67-button"> ค้นหาข้อมูล </button>
				</td>
			</tr>
		</table>
		<br/>
		<c:if test="${!empty listData}">
			<fieldset>
				<legend> แสดงรายการข้อการโอน</legend>
				<br/>
					<table width="100%" class="acc67-grid ui-widget ui-widget-content" border="0">
						<tr>
							<th align="center" class="ui-state-default">สสจ. </th>
							<th align="center" class="ui-state-default">หน่วยบิรการ/คู่สัญญา</th>
							<th align="center" class="ui-state-default">จำนวนเงิน</th>
							<th align="center" class="ui-state-default">สถานะการโอน</th>
						</tr>
						<c:forEach items="${listData}" var="data" varStatus="x">
							<tr class="grid-tr-${x.count % 2}">
								<td align="left">${el:getDataUtil('PAN', data.provinceId)}</td>
								<td align="left">${el:getDataUtil('VN',data.venderCode)}</td>
								<td align="right"><fmt:formatNumber pattern="#,##0.00" value="${data.expenseAmount}" /></td>
								<c:if test="${empty data.reasonCode}">
									<td align="center">
										<select name="reasonCode">
											<option value="">----- เลือก ------</option>
											<c:forEach items="${reasonCode}" var="rc">
												<c:if test="${data.reasonCode == rc.key}" var="selected"/>
												<option value="${rc.key}" ${selected?'selected':''}>${rc.value}</option>
											</c:forEach>
										</select>
									</td>
								</c:if>
								<c:if test="${!empty data.reasonCode}">
									<c:forEach items="${reasonCode}" var="rc">
										<c:if test="${data.reasonCode == rc.key}">
											<td align="left">
												${rc.value}
											</td>
										</c:if>
									</c:forEach>
								</c:if>
								<c:if test="${empty data.reasonCode}">
									<input type="hidden" name="transactionTimestamp2" value="${data.transactionTimestamp}"/>
								</c:if>	
							</tr>
						</c:forEach>
						<c:if test="${fn:contains(auth, 'U')}">
							<tr>
								<td colspan="5" align="center">
									<button class="acc67-button" name="btnEdit" id="btnEdit" type="button" >บันทึก</button>
								</td>
							</tr>
						</c:if>
					</table>
			</fieldset>
		</c:if>
		</form>
	</body>
</html>